package homework.workTest.RegularExpression;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * replaceUrlHead
 *
 * @author byc
 * @date 2021-11-27
 */
public class replaceUrlHead {
    public static void main(String[] args) {
        String url = "https://www.baidu.com:9988/abc/pp/nimasile";

        String pattern = "(https|http)://.*?/";
        String urlHead = "https://xt.wx.js.cegn.cn/wxyw/";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(url);
        String resultUrl = m.replaceFirst(urlHead);

        System.out.println(m);
        System.out.println("---------------");
        System.out.println(resultUrl);
    }
}
